<?php
/**
 * Created by PhpStorm.
 * User: xk_96
 * Date: 2018/1/16
 * Time: 17:11
 */

namespace system\lib;


class Http
{
    public function sendPost($url,$body)
    {
        $opts = array(
            'http' =>
                array(
                    'method' => 'POST',
                    /*'header' => "Content-Type: text/json\r\n",*/
                    'content' => $body,
                    'timeout' => 60
                )
        );
        $context = stream_context_create($opts);
        $result = file_get_contents($url, false, $context);
        return $result;
    }

    public function sendGet($url)
    {
        $opts = array(
            'http' =>
                array(
                    'method' => 'GET',
                    /*'header' => "Content-Type: text/json\r\n",*/
                    'timeout' => 60
                )
        );
        $context = stream_context_create($opts);
        $result = file_get_contents($url, false, null);
        return $result;
    }
}